const express = require('express')
const routerUsers = express.Router()
const expressJoi = require('@escook/express-joi')
const reg_schema = require('../schema/schema')
const handle = require('../router_handler/users')
    // 用户列表
routerUsers.get('/users', handle.getUsers)
    // 添加用户
routerUsers.post('/users', expressJoi(reg_schema.user_create_schema), handle.addUsers)
    // 根据ID查询用户信息
routerUsers.get('/users/:id', handle.search)
    // 修改用户状态
routerUsers.put('/users/:uId/state/:type', handle.changeState)
    // 编辑用户提交
routerUsers.put('/users/:id', expressJoi(reg_schema.user_update_schema), handle.update)
    // 删除单个用户
routerUsers.delete('/users/:id', handle.delete)
    // 分配用户角色
routerUsers.put('/users/:id/role', handle.updateRole)
module.exports = routerUsers